package com.example.mindadinner.net;

import java.lang.reflect.Constructor;


import android.os.Handler;

public class RquestFactory {
	  @SuppressWarnings("unchecked")
	public final static <T extends RequestThread> T createRequestThread(Request request,Handler handler) {
		final Class <? extends RequestThread > requestThreadClass = request.getRequestThreadClass();
			try {
				Constructor<? extends RequestThread> constructor = requestThreadClass.getConstructor(Request.class,Handler.class);
				return (T) constructor.newInstance(request, handler);
			} catch (Exception e) {
				e.printStackTrace();
			}
		return null;
	}
}
